package com.cx.bank.servlet;

import com.cx.bank.pojo.Log;
import com.cx.bank.util.LogUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * 查询日志明细
 * @author jxau_scf
 * @date 2021/8/9 - 16:12
 */
@WebServlet(urlPatterns = "/user/allLog")
public class AllLogServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String userId = req.getParameter("id");

        try {
            //查询出所有log
            List<Log> logList = LogUtil.queryLogByUserId(Integer.valueOf(userId));
            req.setAttribute("logList", logList);
            //服务端跳转
            req.getRequestDispatcher("/WEB-INF/jsp/user/allLog.jsp").forward(req, resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
